<?php
if(!isset($_SESSION)) 
	{ 
		session_start(); 
	}
function getlang(){
		$lang = $_SESSION['lang'];
		if (empty($lang) || $lang == "EN") {
			$value = "../value/value_en.php";
		} else if($lang == "VN") {
			$value = "../value/value_vn.php";
		}
		else {
			$value = "../value/value_kr.php";
		}
		return $value;
	}
$value = getlang();
include($value);
$listapprove=array();
$listapprovename=array();
include '../operations/connection.php';	
function getten($id){
	$sql="select FullName from employee where IDEmployee='$id'";
	$query=mysql_query($sql);
	
	$row=mysql_fetch_array($query);
	
	return $row['FullName'];
}
$_SESSION["groupapp"]=$_GET['q'];
if ($_GET['q']!=0){
	
	$sql="SELECT l.IDEmployee FROM listapprove l WHERE l.IDGroupApprove=".$_GET['q']." ORDER BY l.Order;";
	$query=mysql_query($sql);
	while($row=mysql_fetch_array($query)){
		$mangone=array();
		$listapprove[$row['IDEmployee']]=$mangone;
		$listapprovename[$row['IDEmployee']]=getten($row['IDEmployee']);
	}
	
	$sql="SELECT l.id_manager,l.id_employee FROM list_reference l WHERE l.id_group=".$_GET['q'].";";
	$query=mysql_query($sql);
	$temp="";
	while($row=mysql_fetch_array($query)){
		if ($temp!=$row['id_manager']){
			$mang=array();
			$temp=$row['id_manager'];
		}
		$mang[]=array($row['id_employee'],getten($row['id_employee']));
		$listapprove[$row['id_manager']]=$mang;
		
	}



echo "<table width='100%' class='templ' cellspacing='0'>
            <tr class='titapp titapp2'>
                               	  <td></td>
                                	<td>$l_order</td>
                                	<td><div align='center'><img src='images/approve.png' alt='' width='12px' style='float:left; border:1px solid #eee' />$l_approver</div></td>
                                	<td><div align='center'><img src='images/reference.png' alt='' width='12px' style='float:left; border:1px solid #eee' />$l_reference</div></td>
                           	  </tr>";
$i=1;
foreach ($listapprove as $approve=>$abc){
	
    echo "                         <tr>";
    if($check==$i){
                               echo "<td><input type='radio' name='ra_app' value='".$i."' onclick='handler(this.value)' checked='checked'/></td>";
    }else{
    	echo "<td><input type='radio' name='ra_app' value='".$i."' onclick='handler(this.value)'/></td>";
    }
       echo                          " <td>".$i."</td>";
    
       echo"                           <td>".$listapprovename[$approve]."</td>";
        echo"                          <td>";
                                  foreach ($abc as $hienthi){
                                  		
                                  		echo"<div><a onclick='delReference(".$hienthi[0].")'><img src='images/del.png'  alt='' width='10px' style='border:1px solid #eee; margin-right:10px' /></a>".$hienthi[1]."</div>";
                                  }             
                                  echo"</td>";
       echo                    "   </tr>";
                              
                              $i++;
}                              
                              
echo "                         <tr class='titapp titapp22'>
                               	  <td colspan='4'><div align='center'>
                               	    <input type='button' value='Delete' onclick='delApprove()'  class='btnupbg btnupload' />
                           	      </div></td>
                           	  </tr>
                          </table>";
}else{
	echo "<table width='100%' class='templ' cellspacing='0'>
            <tr class='titapp titapp2'>
                               	  <td></td>
                                	<td>$l_order</td>
                                	<td><div align='center'><img src='images/approve.png' alt='' width='12px' style='float:left; border:1px solid #eee' />$l_approver</div></td>
                                	<td><div align='center'><img src='images/reference.png' alt='' width='12px' style='float:left; border:1px solid #eee' />$l_reference</div></td>
                           	  </tr>";
}
	$_SESSION['listapprove']=$listapprove;
	$_SESSION['listapprovename']=$listapprovename;
?>